
#Goal for this example:

#link to a c++11 library that has an INTERFACE_COMPILE_OPTIONS that
#contains INTERFACE_POSITION_INDEPENDENT_CODE, trying to trigger
#the incorrect FPIC flags be passed to nvcc


add_library(cpp_with_fpic SHARED static.cpp)
target_compile_features(cpp_with_fpic PUBLIC cxx_constexpr)
set_property(TARGET cpp_with_fpic APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON")

add_executable(cuda_bad_fpic main.cu)
target_link_libraries(cuda_bad_fpic PRIVATE cpp_with_fpic)

# comment out these two to show how Qt5 fails
find_package(Qt5Core)
if(Qt5Core)

#we need to work around a Qt5Core bug
get_property(core_options TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS)
string(REPLACE "-fPIC" "" new_core_options ${core_options})
set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS ${new_core_options})
set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON")

target_link_libraries(cuda_bad_fpic PUBLIC Qt5::Core)
endif()
